home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / pc / 3DGPL.ZIP / 3DGPL / CODE / GRAPHICS / GRP-TEXT.C < prev   
Encoding:
C/C++ Source or Header  |  1995-06-20  |  3.8 KB  |  81 lines

  1. /** 3DGPL *************************************************\
  2.  * (8bit deep bitmap)                                     *
  3.  * 2D graphics and 2D clipping.                           *
  4.  *                                                        *
  5.  *  Defines:                                              *
  6.  *   G_text                  rendering a text string.     *
  7.  *                                                        *
  8.  *  (6/1995) By Sergei Savhenko. (savs@cs.mcgill.ca).     *
  9.  *  Copyright (c) 1995 Sergei Savchenko.                  *
  10.  *  THIS SOURCE CODE CAN'T BE USED FOR COMERCIAL PURPOSES *
  11.  *  WITHOUT AUTHORISATION                                 *
  12. \**********************************************************/
  13.  
  14. #include "../hardware/hardware.h"           /* hardware specific stuff */
  15. #include "../graphics/graphics.h"           /* graphics functions */
  16.  
  17. extern unsigned char *G_buffer;             /* the bitmap's bits */
  18.  
  19. unsigned char G_font[354]=                  /* The 8x6 font */
  20.  0x00,0x00,0x00,0x00,0x00,0x00, 0x30,0x30,0x30,0x00,0x30,0x00,
  21.  0xd8,0x90,0x00,0x00,0x00,0x00, 0x6c,0xfe,0x6c,0xfe,0x6c,0x00,
  22.  0x7e,0xd0,0x7c,0x16,0xfc,0x00, 0xcc,0x18,0x30,0x60,0xcc,0x00,
  23.  0x60,0x90,0x74,0xd8,0x6c,0x00, 0x30,0x20,0x00,0x00,0x00,0x00,
  24.  0x60,0xc0,0xc0,0xc0,0x60,0x00, 0x18,0x0c,0x0c,0x0c,0x18,0x00,
  25.  0x6c,0x38,0xfe,0x38,0x6c,0x00, 0x00,0x30,0xfc,0x30,0x00,0x00,
  26.  0x00,0x00,0x00,0x30,0x20,0x00, 0x00,0x00,0x7c,0x00,0x00,0x00,
  27.  0x00,0x00,0x00,0x00,0xc0,0x00, 0x0c,0x18,0x30,0x60,0xc0,0x00,
  28.  0x78,0x84,0x84,0x84,0x78,0x00, 0x04,0x0c,0x14,0x04,0x04,0x00,
  29.  0x78,0x84,0x18,0x20,0x7c,0x00, 0x78,0x04,0x38,0x04,0x78,0x00,
  30.  0x84,0x84,0xfc,0x04,0x04,0x00, 0xfc,0x80,0xf8,0x04,0xf8,0x00,
  31.  0x30,0x40,0xf8,0x84,0x78,0x00, 0xfc,0x04,0x08,0x10,0x10,0x00,
  32.  0x78,0x84,0x78,0x84,0x78,0x00, 0x78,0x84,0x7c,0x08,0x30,0x00,
  33.  0x00,0x30,0x00,0x30,0x00,0x00, 0x00,0x30,0x00,0x30,0x20,0x00,
  34.  0x30,0x60,0xc0,0x60,0x30,0x00, 0x00,0x7c,0x00,0x7c,0x00,0x00,
  35.  0x30,0x18,0x0c,0x18,0x30,0x00, 0x78,0xcc,0x18,0x00,0x18,0x00,
  36.  0x78,0xcc,0xdc,0xc0,0x7c,0x00, 0x30,0x48,0x84,0xfc,0x84,0x00,
  37.  0xf8,0x84,0xf8,0x84,0xf8,0x00, 0x7c,0x80,0x80,0x80,0x7c,0x00,
  38.  0xf8,0x84,0x84,0x84,0xf8,0x00, 0xfc,0x80,0xf0,0x80,0xfc,0x00,
  39.  0xfc,0x80,0xf0,0x80,0x80,0x00, 0x7c,0x80,0x84,0x84,0x7c,0x00,
  40.  0x84,0x84,0xfc,0x84,0x84,0x00, 0x10,0x10,0x10,0x10,0x10,0x00,
  41.  0x04,0x04,0x04,0x84,0x78,0x00, 0x84,0x88,0xf0,0x88,0x84,0x00,
  42.  0x80,0x80,0x80,0x80,0xfc,0x00, 0x82,0xc6,0xaa,0x92,0x82,0x00,
  43.  0x84,0xc4,0xa4,0x94,0x8c,0x00, 0x78,0x84,0x84,0x84,0x78,0x00,
  44.  0xf8,0x84,0xf8,0x80,0x80,0x00, 0x78,0x84,0x84,0x78,0x1c,0x00,
  45.  0xf8,0x84,0xf8,0x90,0x88,0x00, 0x7c,0x80,0x78,0x04,0xf8,0x00,
  46.  0xfe,0x10,0x10,0x10,0x10,0x00, 0x84,0x84,0x84,0x84,0x78,0x00,
  47.  0x84,0x84,0x84,0x48,0x30,0x00, 0x82,0x82,0x92,0xaa,0x44,0x00,
  48.  0x84,0x48,0x30,0x48,0x84,0x00, 0x88,0x88,0x50,0x20,0x20,0x00,
  49.  0xf8,0x10,0x20,0x40,0xf8,0x00
  50. };
  51.  
  52. /**********************************************************\
  53.  *  Rendering a text string, no clipping is performed !   *
  54. \**********************************************************/
  55.  
  56. void G_text(int x,int y,char *string,register unsigned char colour)
  57. {
  58.  int nm,i,j;
  59.  unsigned char  cur;
  60.  unsigned char  *adr,*l_adr;
  61.  
  62.  adr=G_buffer+HW_SCREEN_X_SIZE*y+x;         /* Where in the screen buffer */
  63.  
  64.  while(*string!='\0')                       /* until the end of the string */
  65.  {
  66.   nm=((*string++)-' ');                     /* Starting from space */
  67.   if(nm>58) nm-=' ';                        /* to uppercase 58='Z'-' ' */
  68.   nm*=6;                                    /* 6 bytes per char */
  69.   for(i=0,l_adr=adr;i<6;i++,l_adr+=HW_SCREEN_X_SIZE)
  70.   {
  71.    cur=G_font[nm++];
  72.    for(j=0;j<8;j++)
  73.     if(cur&(0x80>>j)) *(l_adr+j)=colour;
  74.   }
  75.   adr+=8;                                   /* Next word */
  76.  }
  77. }
  78.  
  79. /**********************************************************/
  80.